package com.yykj.base.server.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yykj.base.client.dto.BaseDepartmentDTO;
import com.yykj.base.client.dto.BaseOfficerDTO;
import com.yykj.base.client.dto.WordBriefInfo;
import com.yykj.base.client.dto.template.ConsultationTemplateDTO;
import com.yykj.base.client.dto.template.ConsultationTemplateFieldDTO;
import com.yykj.base.client.dto.template.ConsultationTemplateFieldListDTO;
import com.yykj.base.client.dto.template.FormFieldDTO;
import com.yykj.base.server.service.BaseService;
import com.yykj.base.server.service.ConsultationTemplateService;
import com.yykj.base.server.service.FormFieldService;
import com.yykj.base.server.service.WordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "内部使用接口-外部不用")
@RestController
@RequestMapping("/api/proto/base")
public class ProtoBaseController {

    @ApiOperation("科室--列表")
    @GetMapping("/department")
    public List<BaseDepartmentDTO> getBaseDepartment() {
        return baseService.getBaseDepartment();
    }

    @ApiOperation("科室--修改")
    @PostMapping("/department/edit")
    public BaseDepartmentDTO editBaseDepartment(@RequestBody BaseDepartmentDTO dto) {
        return baseService.editBaseDepartment(dto);
    }

    @ApiOperation("科室--添加")
    @ApiOperationSupport(ignoreParameters = {"id"})
    @PostMapping("/department/add")
    public BaseDepartmentDTO addBaseDepartment(@RequestBody BaseDepartmentDTO dto) {
        return baseService.editBaseDepartment(dto);
    }

    @ApiOperation("科室--删除")
    @DeleteMapping("/department/delete/{id}")
    public void deleteBaseDepartment(@PathVariable Integer id) {
        baseService.deleteBaseDepartment(id);
    }

    @ApiOperation("职称--列表")
    @GetMapping("/doctor/officer")
    public List<BaseOfficerDTO> getBaseOfficer() {
        return baseService.getBaseOfficer();
    }


    @ApiOperation("获取汉字的拼音码和五笔码")
    @GetMapping("/word/brief/info/{word}")
    public WordBriefInfo getWordBriefInfo(@PathVariable String word) {
        return wordService.getWordBriefInfo(word);
    }

    @ApiOperation("会诊模板 -- 通用字段 -- 添加")
    @PostMapping("/form/field/edit")
    public FormFieldDTO editFormField(@RequestBody FormFieldDTO dto) {
        return formFieldService.editFormField(dto);
    }

    @ApiOperation("会诊模板 -- 通用字段 -- 删除")
    @DeleteMapping("/form/field/delete/{id}")
    public void deleteFormField(@PathVariable Integer id) {
        formFieldService.deleteFormField(id);
    }

    @ApiOperation("会诊模板 -- 通用字段 -- 列表")
    @GetMapping("/form/field/common/list")
    public List<FormFieldDTO> commonFormFieldList() {
        return formFieldService.commonFormFieldList();
    }

    @ApiOperation("会诊模板--添加修改")
    @PostMapping("/consultation/template/edit")
    public ConsultationTemplateDTO editConsultationTemplate(@RequestBody ConsultationTemplateDTO consultationTemplateDTO){
        return consultationTemplateService.editConsultationTemplate(consultationTemplateDTO);
    }

    @ApiOperation("会诊模板--删除模板")
    @DeleteMapping("/consultation/template/delete/{id}")
    public void deleteConsultationTemplate(@PathVariable Integer id){
        consultationTemplateService.deleteConsultationTemplate(id);
    }

    @ApiOperation("会诊模板--列表")
    @GetMapping("/consultation/template/list")
    public List<ConsultationTemplateDTO> listConsultationTemplate(){
        return consultationTemplateService.listConsultationTemplate();
    }

    @ApiOperation("会诊模板--普通字段 -- 添加")
    @PostMapping("/consultation/template/field/edit")
    public void editConsultationTemplateFields(@RequestBody ConsultationTemplateFieldListDTO listDTO){
        consultationTemplateService.editConsultationTemplateFields(listDTO);
    }

    @ApiOperation("会诊模板--普通字段 -- 删除")
    @DeleteMapping("/consultation/template/field/delete/{id}")
    public void deleteConsultationTemplateFields(@PathVariable Integer id){
        consultationTemplateService.deleteConsultationTemplateFields(id);
    }

    @ApiOperation("会诊模板 -- 字段列表")
    @PostMapping("/consultation/template/field/list/{id}")
    public List<ConsultationTemplateFieldDTO> listConsultationTemplateFields(@PathVariable Integer id){
        return consultationTemplateService.listConsultationTemplateFields(id);
    }

    private ConsultationTemplateService consultationTemplateService;

    private FormFieldService formFieldService;

    private BaseService baseService;

    private WordService wordService;

    @Autowired
    public void setHospitalTypeService(BaseService baseService) {
        this.baseService = baseService;
    }

    @Autowired
    public void setWordService(WordService wordService) {
        this.wordService = wordService;
    }

    @Autowired
    public void setFormFieldService(FormFieldService formFieldService) {
        this.formFieldService = formFieldService;
    }

    @Autowired
    public void setConsultationTemplateService(ConsultationTemplateService consultationTemplateService) {
        this.consultationTemplateService = consultationTemplateService;
    }
}
